//
//  CQNewFeatureController.m
//  01-OC微博
//
//  Created by 陈乾 on 15/10/27.
//  Copyright © 2015年 陈乾. All rights reserved.
//

#import "CQNewFeatureController.h"
#import "CQNewFeatureCell.h"

@interface CQNewFeatureController ()

@end

@implementation CQNewFeatureController

static NSString * const ID = @"Cell";

#pragma mark - 注意布局参数写这里
-(instancetype)init
{
    //创建流水布局模式
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    //不需要行距
    layout.minimumLineSpacing = 0;
    //需要水平滚动
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
     //和屏幕一样大
    layout.itemSize = [UIScreen mainScreen].bounds.size;
    
    //返回流水布局
    return [super initWithCollectionViewLayout:layout];
}

#pragma mark -viewDidLoad
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //注册cell  注意：当你自定了cell要注册自定义的
    [self.collectionView registerClass:[CQNewFeatureCell class] forCellWithReuseIdentifier:ID];
    
    //不需要水平滚动
    self.collectionView.showsHorizontalScrollIndicator = NO;
    //分页
    self.collectionView.pagingEnabled = YES;
    //不要弹簧效果
    self.collectionView.bounces = NO;
    
    
    
}


#pragma mark - 数据源方法
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}

-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  
    CQNewFeatureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    //拼接图片名字
    NSString *imageName = [NSString stringWithFormat:@"new_feature_%ld",indexPath.row + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    //设置cell图片属性
    cell.image = image;
    
    [cell showBeginBtnIndexPath:indexPath];
    
    return cell;

}







@end
